﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ShopSpace.UI.DotNetNukeModules
{
	public class EditModuleControlBase : ModuleControlBase
	{
		protected Nullable<int> editItemId;

		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);
			try
			{
				this.InitEditItemId();
			}
			catch (Exception ex)
			{
				this.HandleException(ex);
			}
		}

		private void InitEditItemId()
		{
			int id;
			if (int.TryParse(Request["Id"], out id))
			{
				this.editItemId = id;
			}
		}

		protected DateTime ItemConcurrencyDate
		{
			get
			{
				if (ViewState["ItemConcurrencyDate"] != null)
				{
					return (DateTime)ViewState["ItemConcurrencyDate"];
				}
				else
				{
					throw new Exception("ItemConcurrencyDate was not set");
				}
			}
			set
			{
				ViewState["ItemConcurrencyDate"] = value;
			}
		}
	}
}
